Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recode cob_decimal_pow function - Fix for #924, #925, #989 - add test cases for power operator #182

Open
wants to merge 4 commits into
base: gcos4gnucobol-3.x
Choose a base branch
from

Conversation

denishug
Copy link

No description provided.

- Fixe #924, #925, #989
- add tests case for power operator
@engboris engboris requested a review from GitMensch September 26, 2024 08:57
libcob/intrinsic.c Outdated Show resolved Hide resolved
@engboris engboris requested review from engboris and removed request for engboris September 26, 2024 17:22
@engboris
Copy link
Contributor

Hello @denishug and thank you for your contribution.

It is usually requested that contributors add an entry to ChangeLog files when modifying the source code. Here, I believe libcob/ChangeLog must be modified. There is a strict formatting (number of spaces, difference between space and tab).

Example in our PR #191 (merged)

libcob/ChangeLog Outdated Show resolved Hide resolved
libcob/ChangeLog Outdated Show resolved Hide resolved
/* Fix #925 : Avoid GMPLIB CRASH */

mpf_set(cob_mpft3,cob_mpft) ;
if ( sign_nbr == -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove space before condition


Process_case_0:
if (sign_nbr == 0) {
if ( sign_exp == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove space before condition

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

libcob/intrinsic.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this nice piece of work. I think the Changelog entries could be improved and there are some code parts + formatting, but overall quite good!

ChangeLog Outdated Show resolved Hide resolved
libcob/ChangeLog Outdated Show resolved Hide resolved
AT_CHECK([$COMPILE prog.cob], [0], [], [])
AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], [])
AT_CLEANUP

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor beautify: please separate test cases with a double empty line - also above

AT_CLEANUP

AT_SETUP([Power size error and limits cases 2])
AT_KEYWORDS([POWER])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Words that are in AT_SETUP are automatically added to the keyword list. Replacing it with the main statement - here COMPUTE - would be useful (also applies above).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add an m4 comment about which tests are for which bug report - this provides more context and is also useful in the future

break;

case 0:
goto Process_case_0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a single case for this - please inline instead of using goto

mpz_set_ui (pd1->value, 1UL);
pd1->scale = 0;
return;
goto Compute_Power;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please reorder that case to have zero first, this can then return while the fall-through of 1/-1 is easier to follow and we don't need the Compute_Power label any more

Comment on lines 3170 to 3176
sign_nbr = mpz_sgn(pd1->value);
sign_exp = mpz_sgn(pd2->value);

power_case = sign_nbr * sign_exp;

cob_trim_decimal(pd2);
cob_trim_decimal(pd1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please reformat to use a space before the parenthesis (also applies to other places)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

libcob/intrinsic.c Outdated Show resolved Hide resolved
libcob/intrinsic.c Outdated Show resolved Hide resolved
@engboris engboris changed the title Recode cob_decimal_pow function - Fixe #924, #925, #989 - add tests case for power operator Recode cob_decimal_pow function - Fix #924, #925, #989 - add tests case for power operator Oct 21, 2024
@engboris engboris changed the title Recode cob_decimal_pow function - Fix #924, #925, #989 - add tests case for power operator Recode cob_decimal_pow function - Fix for #924, #925, #989 - add tests case for power operator Oct 21, 2024
@engboris engboris changed the title Recode cob_decimal_pow function - Fix for #924, #925, #989 - add tests case for power operator Recode cob_decimal_pow function - Fix for #924, #925, #989 - add test cases for power operator Oct 21, 2024
@GitMensch
Copy link
Collaborator

I've fixed the merge conflicts in the Changelogs, resolving all open issues on these.
There are still (minor) open issues to the other two changed files with a note "done", but not push. Please git pull to get the current changes in (no need for Changelog updates as long as these are all changes to your previous ones), then review your changes / check those in and push them back.

Otherwise I can also handle that when doing the commit upstream - just give me a note how we want to handle that.

run_fundametal.at : add #1020 ticket test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants